package com.storeapp.entity.domain;

import java.util.Collection;
import java.util.Date;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.GeneratedValue;

import org.hibernate.annotations.Fetch;
import org.hibernate.annotations.FetchMode;
import org.hibernate.annotations.LazyCollection;
import org.hibernate.annotations.LazyCollectionOption;

@Entity
@Table(name = "deal_order")
public class DealOrder {
	private Long id;
	private Date purchaseDate;
	private double totalPrice;
	private Collection<Item> items;
	private MyCustomer myCustomer;

	public DealOrder(){}
	
	public DealOrder(Date purchaseDate, double totalPrice) {
		super();
		this.purchaseDate = purchaseDate;
		this.totalPrice = totalPrice;
	}
	
	@ManyToOne
	public MyCustomer getMyCustomer() {
		return myCustomer;
	}

	public void setMyCustomer(MyCustomer myCustomer) {
		this.myCustomer = myCustomer;
	}
	
	@OneToMany(mappedBy="dealOrder", cascade={CascadeType.ALL})
	public Collection<Item> getItems() {
		return items;
	}

	public void setItems(Collection<Item> items) {
		this.items = items;
	}

	@Id
	@GeneratedValue
	public Long getId() {
		return id;
	}
	public void setId(Long id) {
		this.id = id;
	}
	
	@Column(nullable = false)
	public Date getPurchaseDate() {
		return purchaseDate;
	}
	public void setPurchaseDate(Date purchaseDate) {
		this.purchaseDate = purchaseDate;
	}
	
	@Column(nullable = false)
	public double getTotalPrice() {
		return totalPrice;
	}
	public void setTotalPrice(double totalPrice) {
		this.totalPrice = totalPrice;
	}
}
